package com.design.pattern.abstractFactory.factory;

import com.design.pattern.abstractFactory.car.Benz;
import com.design.pattern.abstractFactory.car.Bmw;

/**
 * 汽车工厂
 */
public class CarFactory implements AbstractFactory {

    @Override
    public com.design.pattern.abstractFactory.car.CarFactory carFactory(String type) {
        return switch (type) {
            case "bmw" -> new Bmw();
            case "benz" -> new Benz();
            default -> throw new RuntimeException("未找到对应的汽车生产商");
        };
    }
}
